<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="css/uploadify.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	
	<script src="js/jquery.form.js" type="text/javascript"></script>
	<script src="js/uploadify/swfobject.js" type="text/javascript" ></script>
	<script src="js/uploadify/jquery.uploadify.v2.1.4.min.js" type="text/javascript" ></script>
	
	<script language="javascript" type="text/javascript">
	    $(document).ready(function(){
	    	
	    	$("#uploadify").uploadify({
                'uploader'       : 'uploadify.swf',
                'script'         : 'Upload.action',
                'cancelImg'      : 'cancel.png',
                'folder'         : 'upload/',
                'queueID'        : 'fileQueue',
                'fileExt'        : '*.rar;*.doc;*.tar', //允许文件上传类型,和fileDesc一起使用.
                'fileDesc'       : '*.rar;*.doc;*.tar',  //将不允许文件类型,不在浏览对话框的出现.
                'auto'           : true,
                'multi'          : false,
                'onComplete':function(event,queueId,fileObj,response,data){
                        $('#info').text($('#info').text() + ''+response+'');//在页面上显示文件相对路径
                }
        	});
	    	/*	    		    	
	    	$("#upload").submit(function(){	    		
	    		//var params=$("#upload").formSerialize();//表单序列化				
				
				$("#upload").ajaxSubmit(function (options) {
  					var json = eval("(" + options + ")");
  					if (json.state == 1) {
   						alert("保存成功!");
  					} else{
	   					if (json.state == 0) {
	    					alert("保失败存!");
	   					}
  					}
 				});
				
	
				//防止普通浏览器提交表单
				return false;		
	    	});	
	    	*/		
	    });
		
		function update_page (json) { //回传函数实体，参数为XMLhttpRequest.responseText
           alert(json);
           var str="state:"+json.state+"";
           str+="errorMsg:"+json.errorMsg+"";
           str+="savedFileName:"+json.savedFileName+"";
           $("#result").html(str);
       }
	</script>
  </head>
  
  <body>
  <div id="container">
  		<div id="testdiv"></div>
        <div id="fileQueue"></div>
        <div class="btn-group">
        <input type="file" name="uploadify" id="uploadify" />
        <a href="javascript:jQuery('#uploadify').uploadifyUpload()" class="btn">上传</a>
        <a href="javascript:jQuery('#uploadify').uploadifyClearQueue()"class="btn">取消上传</a>
        </div>

        <div id="2info"><textarea name="comment" id="info" tabindex="4" rows="2" cols="20"></textarea>
  </div>
</div>
  
   
   <div id="result" style="width:200px;height:50px;background-color:#aa0;border:1px solid #a00;">
   
   </div>
  </body>
</html>
